package day17.myRelect;

import java.lang.reflect.Method;

public class RelectDemo {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //method1();
        //method2();
        //method3();
        //method4();
        //method5();
    }

    private static void method5() throws ClassNotFoundException, NoSuchMethodException {
        Class clazz = Class.forName("day17.myRelect.Student");
        Method function1 = clazz.getMethod("function1");
        System.out.println(function1);
    }

    private static void method4() throws ClassNotFoundException, NoSuchMethodException {
        Class clazz = Class.forName("day17.myRelect.Student");
        Method show = clazz.getDeclaredMethod("show");
        System.out.println(show);
    }

    private static void method3() throws ClassNotFoundException {
        Class clazz = Class.forName("day17.myRelect.Student");
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            System.out.println(declaredMethod);
        }
    }

    private static void method2() throws ClassNotFoundException {
        Class clazz = Class.forName("day17.myRelect.Student");
        Method[] methods = clazz.getMethods();
        for (Method method : methods) {
            System.out.println(method);
        }
    }

    private static void method1() throws ClassNotFoundException, NoSuchMethodException {
        Class clazz = Class.forName("day17.myRelect.Student");
        Method method = clazz.getMethod("function2", String.class);
        System.out.println(method);
    }
}
